package com.zfc.life.controller.backend;


import com.zfc.life.comm.AjaxResult;
import com.zfc.life.domain.Resource;
import com.zfc.life.utils.file.FileUploadUtils;
import com.zfc.life.utils.file.QiniuUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author zfc
 * @since 2024-05-23
 */
@RestController
@RequestMapping("/backend/resource")
public class ResourceController {

    @PostMapping("/upload")
    public AjaxResult handleFileUpload(HttpServletRequest request) throws IOException {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        MultipartFile multipartFiles = multipartRequest.getFile("file");
        String image_url = FileUploadUtils.uploadFile(multipartFiles);

        return AjaxResult.success(image_url);
    }




}
